package main

import "fmt"

//练习4：验证用户名密码是否正确
//var userList = map[string]map[string]string{
//	"root":{"password":"123456", "tel":"158xxxxxxxx"},
//	"admin":{"password":"123456", "tel":"158xxxxxxxx"},
//	"xiaoming":{"password":"123456", "tel":"158xxxxxxxx"}}
//输入用户名密码，进行验证，验证成功后，输出手机号码

func main(){
	var userList = map[string]map[string]string{
			"root":{"password":"123456", "tel":"15364005982"},
			"admin":{"password":"123456", "tel":"13077304764"},
			"xiaoming":{"password":"123456", "tel":"15364006635"},
	}
	var username string
	var passwd string
	var tel string
	fmt.Println("请输入用户名:")
	fmt.Scan(&username)
	fmt.Println("请输入密码:")
	fmt.Scan(&passwd)
	fmt.Println("请输入电话号码:")
	fmt.Scan(&tel)
	flag := false
	for uname,uinfo := range userList{
		if username == uname && passwd == uinfo["password"] && tel == uinfo["tel"]{
			flag = true
		}

	}
	if flag{
		fmt.Println("验证成功!")
		fmt.Printf("%v欢迎您\n",tel)
	}else{
		fmt.Println("验证失败!")
	}

}

